package com.central.user.controller

import com.central.common.annotation.LoginUser
import com.central.common.model.CommonResult
import com.central.common.model.SysUser
import com.central.user.handler.UpdateUserInfoDto
import com.central.user.handler.UserDetailVo
import com.central.user.handler.UserHandler
import com.central.user.handler.UserInfo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import springfox.documentation.annotations.ApiIgnore

/**
 * @author  fly
 * @date  2021/5/27 18:05
 * @version 1.0
 */
@RestController
@RequestMapping("/userHandler")
@Api(tags = ["(小程序) 用户信息"])
open class UserHandleController {

    @Autowired
    private lateinit var userHandler: UserHandler

    @ApiOperation("获取app用户信息")
    @PostMapping("/getAppUserInfo")
    fun getAppUserInfo(@ApiIgnore @LoginUser(isFull = true) sysUser: SysUser): CommonResult<UserDetailVo> = userHandler.getAppUserInfo(sysUser)


    @ApiOperation("修改用户背景图片")
    @PostMapping("/updateUserBackGroundPic")
    fun updateUserBackGroundPic(backPic: String, @ApiIgnore @LoginUser(isFull = true) sysUser: SysUser): CommonResult<Boolean> = userHandler.updateUserBackGroundPic(backPic, sysUser)


    @ApiOperation("修改用户信息")
    @PostMapping("/updateUserInfo")
    fun updateUserInfo(updateUserInfoDto: UpdateUserInfoDto, @ApiIgnore @LoginUser(isFull = true) sysUser: SysUser): CommonResult<Boolean> = userHandler.updateUserInfo(updateUserInfoDto, sysUser)


    @ApiOperation("获取用户信息")
    @PostMapping("/getUserInfo")
    fun getUserInfo(@ApiIgnore @LoginUser(isFull = true) sysUser: SysUser): CommonResult<UserInfo> = userHandler.getUserInfo(sysUser)
}